package com.learn.reflect;

import sun.misc.ProxyGenerator;

import java.io.File;
import java.io.FileOutputStream;

/**
 * Created by chenxin on 2017/11/30.
 */
public class ProxyGeneratorTest {

    public static void main(String[] args) {
        IService service = new ServiceImpl();
        byte[] generateProxyClass =
                ProxyGenerator.generateProxyClass("IService$1", service.getClass().getInterfaces());
        try {
            File file = new File("/Users/chenxin/Downloads/IService$1.class");
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(generateProxyClass);
            fos.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
